<?php
/**
 * @Notes:【】
 * @Date: 2022-08-06 18:39
 */

namespace App\Controller\Ocean;

use App\Middleware\AuthTokenMiddleware;
use App\Service\Ocean\OceanUserRubbishService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Middleware;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @Notes:【】
 * @Date: 2022-08-06 19:11
 * @ApiController(prefix="ocean/user/rubbish")
 * @Middleware(AuthTokenMiddleware::class)
 */
class OceanUserRubbishController extends BaseController
{
    /**
     * @Inject()
     * @var OceanUserRubbishService
     */
    protected $oceanUserRubbishService;


    /**
     * @Notes:【】
     * @Date: 2022-08-06 19:12
     * @PostApi(path="lists")
     */
    public function lists()
    {
        $params = $this->getParams();
        $params->offsetSet('user_id', $this->getUid());
        $data = $this->oceanUserRubbishService->page(false)->lists($params);
        _SUCCESS($data);
    }

    /**
     * @PostApi(path="clear")
     * @FormData(key="id")
     */
    public function clear(){
        $id = $this->getParams()->get('id');
        $userId = $this->getUid();
        $this->oceanUserRubbishService->clear($id,$userId);
        _SUCCESS();
    }

}